package com.jjh.controller;

import com.jjh.consts.Result;
import com.jjh.pojo.Flavour;

import com.jjh.pojo.Tag;
import com.jjh.service.TagService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/tag")
public class TagController {


    @Resource
    private TagService tagService;


    @GetMapping
    public Result getFlavour(){
        return tagService.getAll();
    }
    @PostMapping("/add")
    public Result addFlavour(@RequestBody Tag tag){
        return  tagService.addOne(tag);
    }
    @PutMapping("/update")
    public Result updateFlavour(@RequestBody Tag tag){
        return tagService.updateOne(tag);
    }

    @PostMapping("/delete")
    public Result deleteUsers(@RequestBody Map<String, List<Integer>> map){
        List<Integer> ids = map.get("ids");
        return tagService.deleteByIds(ids);
    }









}
